<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // vue2 响应式原理
    var obj = {
      name: "why"
    }
    var _name = ""
    Object.defineProperty(obj, 'name', {
      configurable: true,
      enumerable: false,
      set: function (value) {
        console.log("set方法被调用了", value)
        _name = value
      },
      get: function () {
        console.log("get方法被调用了", _name)
        return _name
      }
    })

    obj.name = "kobe"
    obj.name = "jame"
    obj.name = "curry"
    obj.name = "coderwhy"

    console.log(obj.name)
  </script>
</body>

</html>